/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GUIPrincipal.java
 *
 * Created on 17/02/2011, 12:58:46
 */

package visao.gui;

import java.beans.PropertyVetoException;
import javax.swing.JFrame;
import visao.ouvinte.OuvinteDeTemplatePai;

/**
 *
 * @author Marlon
 */
public class GUIPrincipal extends javax.swing.JFrame {

    /** Creates new form GUIPrincipal */
    public GUIPrincipal() {
        initComponents();
      this.setExtendedState(JFrame.MAXIMIZED_BOTH);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        desktopPane = new javax.swing.JDesktopPane();
        menuBar = new javax.swing.JMenuBar();
        menuCadastro = new javax.swing.JMenu();
        menuCEspeciePagamento = new javax.swing.JMenuItem();
        jTemplateTeste = new javax.swing.JMenuItem();
        menuLancamento = new javax.swing.JMenu();
        menuRelatorio = new javax.swing.JMenu();
        menuInformacoes = new javax.swing.JMenu();
        menuSair = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Contolar as Despesas Pessoais");

        menuCadastro.setText("Cadastros");

        menuCEspeciePagamento.setText("Espécie Despesas");
        menuCEspeciePagamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCEspeciePagamentoActionPerformed(evt);
            }
        });
        menuCadastro.add(menuCEspeciePagamento);

        jTemplateTeste.setText("Template Testes");
        jTemplateTeste.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTemplateTesteActionPerformed(evt);
            }
        });
        menuCadastro.add(jTemplateTeste);

        menuBar.add(menuCadastro);

        menuLancamento.setText("Lançamentos");
        menuBar.add(menuLancamento);

        menuRelatorio.setText("Relatórios");
        menuBar.add(menuRelatorio);

        menuInformacoes.setText("Informações");
        menuInformacoes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuInformacoesActionPerformed(evt);
            }
        });
        menuBar.add(menuInformacoes);

        menuSair.setText("Sair");
        menuSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuSairActionPerformed(evt);
            }
        });
        menuBar.add(menuSair);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuInformacoesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuInformacoesActionPerformed

        if ((guiSobre == null) || (!guiSobre.isVisible())) {
            guiSobre = new GUISobre();
            desktopPane.add(guiSobre);
            guiSobre.setPosicao();
            guiSobre.setVisible(true);
        }
    }//GEN-LAST:event_menuInformacoesActionPerformed

    private void menuSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSairActionPerformed
      this.dispose();        // TODO add your handling code here:
    }//GEN-LAST:event_menuSairActionPerformed
    private GUITemplatePai guiTemplatePai;

    private GUITemplateTeste guiTemplateTeste;

    private void menuCEspeciePagamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCEspeciePagamentoActionPerformed

        if ((guiTemplatePai == null) || (!guiTemplatePai.isVisible())) {
           guiTemplatePai = new GUITemplatePai();
           OuvinteDeTemplatePai ouvinte = new OuvinteDeTemplatePai(guiTemplatePai);
           desktopPane.add(guiTemplatePai);
           guiTemplatePai.setPosicao();
           guiTemplatePai.setVisible(true);
        }
         try {
             guiTemplatePai.setSelected(true);
         } catch (PropertyVetoException exc) {
             StringBuffer mensagem = new StringBuffer();
             mensagem.append("Não foi possível selecionar a janela!");
             mensagem.append("\nMotivo: " + exc.getMessage());
            GUIMensagem.exibirMensagem(mensagem.toString(), "Despesas - Especie pagamento", true);
        }
    }//GEN-LAST:event_menuCEspeciePagamentoActionPerformed

    private void jTemplateTesteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTemplateTesteActionPerformed
       if ((guiTemplateTeste == null) || (!guiTemplateTeste.isVisible())) {
            guiTemplateTeste = new GUITemplateTeste();
            desktopPane.add(guiTemplateTeste);
            //guiSobre.setPosicao();
            guiTemplateTeste.setVisible(true);
       }
    }//GEN-LAST:event_jTemplateTesteActionPerformed

    /**
    * @param args the command line arguments
    */
   

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane desktopPane;
    private javax.swing.JMenuItem jTemplateTeste;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem menuCEspeciePagamento;
    private javax.swing.JMenu menuCadastro;
    private javax.swing.JMenu menuInformacoes;
    private javax.swing.JMenu menuLancamento;
    private javax.swing.JMenu menuRelatorio;
    private javax.swing.JMenu menuSair;
    // End of variables declaration//GEN-END:variables
    private GUISobre guiSobre;
}
